Day 11
No Headings
The table of contents shows headings in notebooks and supported files.
- File
- Edit
- View
- Run
- Kernel
- Settings
- Help
Kernel status: Idle
[1]:
Selection deleted
import pandas as pd
data = {
'Account_Balance': [1000, 2500, 1200, 5000, 3000, 1500, 2000, 4500, 3500, 1800],
'Branch': ['A', 'B', 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B'],
'Transaction_Amount': [200, 500, 300, 800, 600, 200, 100, 700, 900, 400],
}
df = pd.DataFrame(data)
sorted_df = df.sort_values(by='Account_Balance', ascending=False)
print("Sorted Data by Account Balance:")
print(sorted_df.head(10))
df['Transaction_Rank'] = df.groupby('Branch')['Transaction_Amount'].rank(ascending=False)
print("\nData with Transaction Rank within Branch:")
print(df)
Sorted Data by Account Balance: Account_Balance Branch Transaction_Amount 3 5000 B 800 7 4500 B 700 8 3500 A 900 4 3000 A 600 1 2500 B 500 6 2000 A 100 9 1800 B 400 5 1500 B 200 2 1200 A 300 0 1000 A 200 Data with Transaction Rank within Branch: Account_Balance Branch Transaction_Amount Transaction_Rank 0 1000 A 200 4.0 1 2500 B 500 3.0 2 1200 A 300 3.0 3 5000 B 800 1.0 4 3000 A 600 2.0 5 1500 B 200 5.0 6 2000 A 100 5.0 7 4500 B 700 2.0 8 3500 A 900 1.0 9 1800 B 400 4.0
[ ]:
Common Tools
No metadata.
Advanced Tools
No metadata.
Anaconda Assistant
AI-powered coding, insights and debugging in your notebooks.
To enable the following extensions, create an account or sign in.
- Anaconda Assistant4.1.0
- Coming soon!
- Data Catalogs
- Panel Deployments
- Sharing
Already have an account? Sign In
For more information, read our Anaconda Assistant documentation.
![Python [conda env:base] *](./Day 11_files/logo-64x64.png)